package com.wlyuan.open.scanner.domain.customer;

import com.wlyuan.open.scanner.dao.entity.MConfigDO;
import com.wlyuan.open.scanner.utils.mappings.MappingInvalid;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

public class CustomerConfigConvert {

    private static final Convert CONVERT = Mappers.getMapper(Convert.class);

    @Mapper(uses = {MappingInvalid.class})
    public interface Convert {
        @Mappings({
                @Mapping(source = "cfgChargemode", target = "chargeMode"),
                @Mapping(source = "cfgPriceunit", target = "priceUnit"),
                @Mapping(source = "cfgInsurance", target = "insure"),
                @Mapping(source = "cfgPick", target = "pick"),
                @Mapping(source = "cfgDelivery", target = "deliver"),
                @Mapping(source = "cfgOnload", target = "onLoad"),
                @Mapping(source = "cfgOffload", target = "offLoad"),
                @Mapping(source = "cfgGoodscategory", target = "goodsCategory"),
                @Mapping(source = "cfgPackagemode", target = "packageMode"),
                @Mapping(source = "cfgCreator", target = "createBy"),
                @Mapping(source = "cfgCreatetime", target = "createAt"),
        })
        CustomerConfig convert(MConfigDO customerDO);

        List<CustomerConfig> convert(List<MConfigDO> list);

    }

    public static List<CustomerConfig> convert(List<MConfigDO> creation) {
        return CONVERT.convert(creation);
    }

    public static CustomerConfig convert(MConfigDO creation) {
        return CONVERT.convert(creation);
    }
}
